package util;

import java.awt.Color;
import java.awt.Composite;
import java.awt.Font;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;

public enum ConfiguringActions implements Action {

	TRANSFORM {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof AffineTransform) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().transform((AffineTransform) params[1]);
				}
			}
		}
	},

	PAINT {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Paint) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setPaint((Paint) params[1]);
				}
			}
		}
	},

	COMPOSITE {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Composite) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setComposite((Composite) params[1]);
				}
			}
		}
	},

	COLOR {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Color) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setColor((Color) params[1]);
				}
			}
		}
	},

	FONT {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Font) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setFont((Font) params[1]);
				}
			}
		}
	},

	CLIP {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Shape) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setClip((Shape) params[1]);
				}
			}
		}
	},

	STROKE {
		@Override
		public void performAction (Object param) {
			if (param instanceof Object[]) {
				Object[] params = (Object[]) param;
				if (params.length == 2 && params[0] instanceof DynamicImage && params[1] instanceof Stroke) {
					DynamicImage image = (DynamicImage) params[0];
					image.getGraphics().setStroke((Stroke) params[1]);
				}
			}
		}
	}

}
